package com.cg.slms.dao;

import java.util.ArrayList;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.cg.slms.domain.Stockin;
import com.cg.slms.domain.Stockorder;

public class StockorderDao implements IStockorderDao{
	private SqlSessionTemplate sqlSession;
	/* 订单查询 */
	public List<Stockorder> findStockorder(Stockorder stockorder){
		List<Stockorder> stockorders=new ArrayList<Stockorder>();
		stockorders=sqlSession.selectList("findStockorder", stockorder);
		//System.out.println("dao::"+stockorder.getClient().getId()+"---"+stockorder.getEmployee().getId()+"---"+stockorder.getMerchandise().getId());
		return stockorders;
	}
	public SqlSessionTemplate getSqlSession() {
		return sqlSession;
	}
	public void setSqlSession(SqlSessionTemplate sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	public boolean addStockorder(Stockorder stockorder) {
		int res = sqlSession.insert("addStockorder",stockorder);
		if(res>0) {
			return true;
		}else {
			return false;
		}
	}
	
	public Stockorder findStockorderById(String id) {
		Stockorder stockorder = sqlSession.selectOne("findStockorderById",id);
		return stockorder;
	}
	
	public boolean updateStockorder(Stockorder stockorder) {
		System.out.println("修改数据："+stockorder.getId()+"--");
		int ref = sqlSession.update("updateStockorder", stockorder);
		if(ref > 0) {
			return true;
		}else {
			return false;
		}
	}
	
	public boolean deleteStockorderById(Stockorder stockorder) {
		int ref = sqlSession.delete("deleteStockorderById",stockorder);
		
		if(ref>0) {
			return true;
		}else {
			return false;
	    }
	}

	
	


}
